<html>
	<head>

		<script type="text/javascript">

		function reverse (s) {
 		 for (var i = s.length - 1, o = ''; i >= 0; o += s[i--]) { }
  		return o;
		}

		function removePuctoation(string)
		{
			string = string.replace("?","");
			string = string.replace(".","");
			string = string.replace(",","");
			string = string.replace("!","");
			string = string.replace("'","");
			string = string.replace("\"","");
			string = string.replace("\\","");
			string = string.replace("/","");
			string = string.replace("+","");
			string = string.replace("-","");
			string = string.replace("!","");
			string = string.replace("@","");
			string = string.replace("#","");
			string = string.replace("$","");
			string = string.replace("%","");
			string = string.replace("^","");
			string = string.replace("&","");
			string = string.replace("*","");
			return string;
		}

		function writeResult(text)
		{
				var output = document.getElementById('output');
				var p = document.createElement("p");
				var nodeText = document.createTextNode(text);
				p.appendChild(nodeText);
				output.appendChild(p);
		}

		function checkPalindrome(string)
		{
			var stringArr = string.split(" ");
			for(var i =0; i<stringArr.length;i++)
			{
				if (stringArr[i].length % 2 == 0) 
				{
					if (stringArr[i].length === 1) {writeResult(stringArr[i]);console.log(stringArr[i])}
					var firsthalf = stringArr[i].slice(0,middleElement);
					var secondhalf = stringArr[i].slice(middleElement,stringArr[i].length)
					if (firsthalf === reverse(secondhalf)) {writeResult(stringArr[i]);console.log(stringArr[i])};
				}
				else
				{
					var middleElement = (stringArr[i].length-1)/2;
					var firsthalf = stringArr[i].slice(0,middleElement);
					//console.log(reverse(firsthalf));
					var secondhalf = stringArr[i].slice(middleElement+1,stringArr[i].length)
					//console.log(reverse(secondhalf));
					if (firsthalf === reverse(secondhalf)) {writeResult(stringArr[i]);console.log(stringArr[i])};
				}
			}
			
		}

		function onClick()
		{
			  var text= 'Hello ABBA madam, ii your mother tongue malayalam?';
			  checkPalindrome(removePuctoation(text))		  		     
		}
		</script>
		<title></title>
	</head>
	<body>
		
		<p>
			Hello ABBA madam, ii your mother tongue malayalam?
		</p>
		<button onclick="onClick()" id="buttonOne">Parse</button>
		<p>
			Output
		</p>
		<div id="output"></div>
	</body>
</html>